
#include "member_BNode.h"
#include "member_BShape.h"

using namespace BWE;

#define n_member(node)			((member_BNode*)node->_ptr)

member_BNode::member_BNode(BNode* node)
{
	boss = node;
	group = 0;
	visible = true;
	dirtySpace = true;
}
member_BNode::~member_BNode()
{

}

void member_BNode::slotShapeFresh(BObject* object, const BValue& value)
{
	boss->emit(Signal_Fresh);
}
void member_BNode::slotShapeDirty(BObject* object, const BValue& value)
{
	dirtyBox = true;
	dirtySpace = true;
	boss->emit(Signal_Dirty);
}
void member_BNode::slotShapeTransform(BObject* object, const BValue& value)
{
	dirtyBox = true;
	dirtySpace = true;
	boss->emit(Signal_Dirty);
}
void member_BNode::slotFreshShapeSpaceTree()
{
	BSpace treeSpace = shapeSpaceTree->space();
	const BSpace& space = boss->space();
	if (treeSpace.contain(space))
		return;
	shapeSpaceTree->reset(space);
	for (int i = 0; i < shapes.size(); i++)
	{
		BShape* shape = shapes[i];
		BSpace space = shape->space();
		auto item = shapeSpaceTree->create(space);
		item->append(shape);
	}
}